import javax.swing.JFrame;
import javax.swing.JPanel;
import javax.swing.border.EmptyBorder;
import javax.swing.JLabel;
import javax.swing.ImageIcon;
import java.awt.Font;
import java.awt.Color;
import javax.swing.JButton;
import java.awt.event.ActionListener;
import java.awt.event.ActionEvent;
import javax.swing.JTextField;


public class WelcomeUi extends JFrame {

	private JPanel contentPane;
	private int counter;
	private JTextField textField;
	
	public WelcomeUi() {
		setResizable(false);
		setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE);
		setBounds(100, 100, 403, 400);
		setTitle("MONOFILIPOLY!");
		contentPane = new JPanel();
		contentPane.setBorder(new EmptyBorder(5, 5, 5, 5));
		setContentPane(contentPane);
		contentPane.setLayout(null);
		
		JPanel panel = new JPanel();
		panel.setBounds(0, 0, 400, 366);
		contentPane.add(panel);
		panel.setLayout(null);
		
		textField = new JTextField();
		textField.setBounds(151, 156, 86, 20);
		panel.add(textField);
		textField.setColumns(10);
		
		JButton btnNewButton = new JButton("LARO!");
		btnNewButton.addActionListener(new ActionListener() {
			public void actionPerformed(ActionEvent arg0)
			{
				counter = Integer.parseInt(textField.getText());
				if(counter<=0){
					javax.swing.JOptionPane.showMessageDialog(null, "Ilagay ang bilang ng maglalaro");
				}
				else if(counter>8)
					javax.swing.JOptionPane.showMessageDialog(null, "Hangan 8 manlalaro lang");
				else{
					Player2Ui page = new Player2Ui(counter);
					page.setVisible(true);
					setVisible(false);
				}
			}
		});
		btnNewButton.setFont(new Font("Tahoma", Font.PLAIN, 16));
		btnNewButton.setBounds(135, 187, 129, 35);
		panel.add(btnNewButton);
		
		
		JLabel lblEnterNumberOf = new JLabel("Ilagay kung ilan ang maglalaro:");
		lblEnterNumberOf.setOpaque(true);
		lblEnterNumberOf.setBounds(107, 136, 190, 14);
		panel.add(lblEnterNumberOf);
		
		JLabel lblWelcome = new JLabel("WELCOME");
		lblWelcome.setOpaque(true);
		lblWelcome.setBackground(new Color(244, 164, 96));
		lblWelcome.setFont(new Font("Tahoma", Font.BOLD, 32));
		lblWelcome.setBounds(112, 72, 166, 53);
		panel.add(lblWelcome);
		
		JLabel lblNewLabel = new JLabel("");
		lblNewLabel.setIcon(new ImageIcon(WelcomeUi.class.getResource("/images/playeryellow.jpg")));
		lblNewLabel.setBounds(0, 0, 400, 370);
		panel.add(lblNewLabel);
	}
}
